import 'package:flutter/material.dart';

class GridViewCase extends StatelessWidget {
  const GridViewCase({super.key});

  @override
  Widget build(BuildContext context) {
  
    // 写法一：常规写法
    return GridView(
      gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
        childAspectRatio: 1 / 1, //宽高比
      ),
      children: [
        Container(color: Colors.red),
        Container(color: Colors.green),
        Container(color: Colors.blue),
        Container(color: Colors.yellow),
        Container(color: Colors.purple),
        Container(color: Colors.orange),
        Container(color: Colors.pink),
        Container(color: Colors.brown),
        Container(color: Colors.teal),
        Container(color: Colors.cyan),
      ],
    );
  }
}
